package fenyu.personblob.bean.databean.logs;

import fenyu.personblob.bean.Bean;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * create at 2018/12/22 7:12
 *
 * @author 纷羽 <gzj0078@gmail.com>
 */
public class LogBean extends Bean {
    @Override
    public String type() {
        return "log";
    }

    private Integer type;

    private String log;

    private Date createTime = new Date();

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getLog() {
        return log;
    }

    public void setLog(String log) {
        this.log = log;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String type = this.type == null ? "INFO" : (this.type == 1 ? "SUCCESS" : (this.type == 2 ? "WARNING" : "ERROR"));
        return "[" + type + "]" + format.format(createTime) + " : " + log;
    }
}
